# @Author   :   hany
# @Time      :  2021/3/10
from basic.device.Android import Android
from airtest.core.api import *
from basic.utils.h5View import H5View


class bsPage(Android):
    # 办事
    bsBtn = "com.cloudbae.lovenanning:id/icon"

    @classmethod
    def clickBsBtn(self):
        self.poco(self.bsBtn)[2].click()
        print("点击政务页面")
        sleep(3)

    @classmethod
    def ifBsIndex(self):
        sleep(3)
        # bsText1 = self.poco(name='主题分类'|| text='主题分类')
        # bsText=bsText1.get_text()
        status = H5View.viewExists('热门办事')
        bsClass = self.poco(text="企业办事").wait(3)
        print('bsClass:', bsClass)
        if bsClass.exists():
            return True

    @classmethod
    def clickBsGuide(self):
        view=H5View.view('办事指南')
        view.click()

    @classmethod
    def getGuideData(self):
        dataList = []
        text = H5View.views("决定机构：.*?")
        for i in text:
            textAll = i.get_text()
            dataList.append(textAll)
        print(dataList)
        return dataList

    @classmethod
    def clickBsCollect(self):
        sleep(3)
        self.poco(text="我的收藏").wait(3).click()


    @classmethod
    def getBsCollect(self):
        collectText = self.poco(text="建设用地（含临时用地）规划许可证核发").wait(5)
        if collectText.exists():
            return True

    @classmethod
    def clickHotBs(self):
        sleep(3)
        self.poco(text="更多").click()

    @classmethod
    def getHotBs(self):
        sleep(3)
        hotText = self.poco(text="办事详情").wait(5)
        b = hotText.exists()
        print("办事详情：", b)
        if b:
            return True